package bairui.international.model.domain.jpa;

/**
 *
 * @see TB_Town 区县
 *
 */
public class TestData_TB_Town
{

	private final static org.apache.commons.text.RandomStringGenerator Generator = new org.apache.commons.text.RandomStringGenerator.Builder().withinRange(new char[][]{{'a','z'}, {'A','Z'}, {'0','9'}}).build();

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@org.springframework.transaction.annotation.Transactional(rollbackFor=java.lang.Throwable.class)
	public static TB_Town saveMust(
		org.springframework.context.ApplicationContext context,
		bairui.international.model.domain.jpa.TB_City city
	){
		org.springframework.data.jpa.repository.JpaRepository repository = (org.springframework.data.jpa.repository.JpaRepository)context.getBean("repository_Town");
		return (TB_Town)repository.save(newMust(
				city
			));
	}
	
	public static TB_Town newMust(
		bairui.international.model.domain.jpa.TB_City city
	){
		return new TB_Town(new TB_Town.MustProperties() {
			/** 城市 */
			@Override public bairui.international.model.domain.jpa.TB_City getCity(){
				return city;
			}
			/** 名称 */
			@Override public String getName(){
				return Generator.generate(0, 20);
			}
			/** 代码 */
			@Override public String getCode(){
				return Generator.generate(0, 10);
			}
		});
	}
	

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@org.springframework.transaction.annotation.Transactional(rollbackFor=java.lang.Throwable.class)
	public static TB_Town saveAll(
		org.springframework.context.ApplicationContext context,
		bairui.international.model.domain.jpa.TB_City city
	,bairui.international.model.domain.jpa.TB_BranchCompany branchCompany
	){
		org.springframework.data.jpa.repository.JpaRepository repository = (org.springframework.data.jpa.repository.JpaRepository)context.getBean("repository_Town");
		return (TB_Town)repository.save(newAll(
				city
				,branchCompany
			));
	}
	
	public static TB_Town newAll(
		bairui.international.model.domain.jpa.TB_City city
	,bairui.international.model.domain.jpa.TB_BranchCompany branchCompany
	){
		return new TB_Town(
			new TB_Town.MustProperties() {
				/** 城市 */
				@Override public bairui.international.model.domain.jpa.TB_City getCity(){
					return city;
				}
				/** 名称 */
				@Override public String getName(){
					return Generator.generate(0, 20);
				}
				/** 代码 */
				@Override public String getCode(){
					return Generator.generate(0, 10);
				}
			},
			new TB_Town.OptionalSingleProperties() {
				/** 分公司 */
				@Override public bairui.international.model.domain.jpa.TB_BranchCompany getBranchCompany(){
					return branchCompany;
				}
			}
		);
	}
	

}
